home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3.iso
/
chapte20
/
ex4.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-19
|
2KB
|
52 lines
#include <genstub.c>
// Window message procedure. Use program from GetPrivateProfileInt as base.
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
char szBuffer[65];
switch (uMsg) // process Windows messages
{
case WM_COMMAND:
switch ( LOWORD( wParam ) )
{
case IDM_TEST:
wsprintf(szBuffer, "%d Ticks have passed.", GetTickCount());
WritePrivateProfileString( "TestSection", // Section name
"TickString", // Key name
szBuffer, // Value to store
"YOUR.INI" ); // INI file name
InvalidateRect( hWnd, NULL, TRUE );
UpdateWindow( hWnd );
break;
case IDM_EXIT:
DestroyWindow( hWnd );
break;
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
GetPrivateProfileString( "TestSection", // Section name
"TickString", // Key name
"TickString Not Set", // Default return value
szBuffer, // Buffer
sizeof( szBuffer ), // Buffer size
"YOUR.INI" ); // Name of INI file
BeginPaint( hWnd, &ps );
TextOut( ps.hdc, 0, 0, szBuffer, lstrlen( szBuffer ) );
EndPaint( hWnd, &ps );
}
break ;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
return( 0L ) ;
}
#include <about.c>